package cn.liwq.study.demo.netty.lab.mahjong.common.codec;

import cn.liwq.study.demo.netty.lab.mahjong.common.protocol.MahjongProtocol;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

/**
 * @author lweiqiang
 * @date 2021/5/8
 */
public class MahjongProtocolDecoder extends MessageToMessageDecoder<ByteBuf> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out)
            throws Exception {
        MahjongProtocol mahjongProtocol = new MahjongProtocol();
        // 解码
        mahjongProtocol.decode(msg);

        out.add(mahjongProtocol);
    }
}
